package com.youlu.campus.website.controller;

import com.youlu.campus.common.base.QResult;
import com.youlu.campus.website.common.enums.PlatformType;
import com.youlu.campus.website.entity.Carousel;
import com.youlu.campus.website.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 轮播图控制器
 */
@RestController
@RequestMapping("/api/carousels")
public class CarouselController {

    @Autowired
    private CarouselService carouselService;

    /**
     * 根据平台获取启用的轮播图列表（前端用）
     *
     * @param platform
     * @return
     */
    @GetMapping("/find-enabled")
    public QResult<List<Carousel>> findListEnabledByPlatform(@RequestHeader(value = "platform", required = false) PlatformType platform) {
        return QResult.success(carouselService.getEnabledCarouselsByPlatform(platform));
    }
}
